<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id='test1'></div>
   

    <script src="../demo1/js/react.development.js"></script>
     <script src="../demo1/js/react-dom.development.js"></script>
     <script src="../demo1/js/babel.min.js"></script>
     <script src="./js/prop-types.js"></script> 
     <!-- 全局有了 PropTypes -->
     <script type="text/babel">
       class Demo extends React.Component{

        state = {
            isHot:true
        }

        showData = ()=>{
            // console.log(this.input);
            alert(this.input.value)
        }

        saveInput = (c)=>{
            // 只负债挂载ref对象  不能有其他实际用途
           console.log(c);
        }



        change = ()=>{
            this.setState({
                isHot:!this.state.isHot
            })
        }
           
        render() {
            let {isHot} = this.state
            return (
                // 回调形式的ref
                // current 当前节点对象  往当前的实例对象挂载input
                // 每次更新页面 ref 的()=>{}会调用两次
                <div>
                    {/*  */}
                    <h2 onClick={this.change}>今天天气很{isHot?'炎热':'凉爽'}</h2>
                    <input ref={currentNode=>this.input = currentNode} type="text"/>
                    <input  ref={this.saveInput} type="text"/>
                    <button  onClick={this.showData} >点我，显示内容</button>    
                </div>
            )   
        }
       }

       ReactDOM.render(<Demo/>,document.querySelector('#test1'))

     </script>
</body>
</html>